#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+1;

int n,k,val;
int arr[N*2][3],len=1;

inline void build(int x){
    int fa = 0;
    bool y;
    for(int i=(1<<20);i>0;i>>=1){
        y = i&x;
        if(arr[fa][y]){
            fa = arr[fa][y];
        }else{
            arr[fa][y] = len;
            fa = len++;
        }
        arr[fa][2]++;
    }
}

inline int query(int x){
    int ans = 0;
    int fa = 0;
    for(int i=(1<<20);i>0;i>>=1){
        bool a = x&i;
        bool b = k&i;
        if(b){
            if(arr[fa][a]!=0){
                ans += arr[arr[fa][a]][2];
            }
            fa = arr[fa][1-a];
        }else{
            fa = arr[fa][a];
        }
        if(fa==0) break;
    }
    if(fa!=0) ans += arr[fa][2];
    return ans;
}

int main(){
    scanf("%d%d",&n,&k);
    memset(arr,0,sizeof(arr));
    for(int i=1;i<=n;i++){
        scanf("%d",&val);
        build(val);
    }
    int ans = 0;
    for(int i=0;i<=2*1e6;i++){
        ans = max(ans,query(i));
        if(ans==n) break;
    }
    printf("%d\n",ans);
    return 0;
}